import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.List;

public class ObjectInputStreamTest02 {
    public static void main(String[] args) {
        try {
            ObjectInputStream ois = new ObjectInputStream(new FileInputStream("C:\\Users\\30539\\Desktop\\text2.txt"));
            //Object obj = ois.readObject();
            //此时的obj引用的是List集合
//            System.out.println(obj instanceof User);
                List<User> users = (List<User>)ois.readObject();
                for(User u: users){
                    System.out.println(u);
                }
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
}
